package example;

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class TestActionListener {
	public static void main(String[] args) {
		TestFrame frame = new TestFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(200, 200);
		frame.setVisible(true);
	}
}

@SuppressWarnings("serial")
class TestFrame extends JFrame {
	public TestFrame() {
		Container container = getContentPane();
		container.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
		JButton btn = new JButton("Component 1");
		container.add(btn);
		btn.addActionListener(new ClickListener());
	}
}

class ClickListener implements ActionListener {

	public void actionPerformed(ActionEvent arg0) {
		JOptionPane.showMessageDialog(null, "OK");
	}

}
